<html>
<head>
    <META http-equiv=Content-Type content="text/html; charset=UTF-8">
    <title>First WebWork Example</title>
    <script type='text/javascript' src='/dwr/interface/userAction.js'></script>
    <script type='text/javascript' src='/dwr/engine.js'></script>
    <script type='text/javascript' src='/dwr/util.js'></script>
     <script type='text/javascript' src='/js/prototype-1.4.0.js'></script>
    <script type="text/javascript">
        var showUser = function(data) {
            var id = data["id"];
            var userList = data["userList"];
            if ($(id).style.display == "none") {
                $(id).style.display = "block";
                var htmlStr = ""; //alert(id);
                for(var i=0;i<userList.length;i++){       //for (var property in userList)
                     var user= userList[i];
                    htmlStr += user.id + " " + user.username + "  " + user.password + "  <input type=\"text\" id=\"show_"+user.id+"\">  <input type=\"button\" value=\"change\" onclick=\"change("+user.id+")\"><br>";
                }
                  //alert(htmlStr);
                $(id).innerHTML = htmlStr;
                return;
            }
            $(id).style.display = "none";
        }
        function change(id){
            //alert(id);
           userAction.updateUser($(eval("show_"+id)).value,id,function(data){alert("save success!")});
              //alert($(eval("show_"+id)).value)
        }
        function changeStatus(obj){
 var oPopup = window.createPopup();
    DWREngine.setPreHook(function() {     //这是正在加载的代码
       obj.innerHTML = "loading...";
        var oPopupBody = oPopup.document.body;
        oPopupBody.innerHTML = "##############################\n\rloading...\n\r##############################";
        oPopup.show((Math.abs(Math.round((document.body.clientWidth-50) / 2))), Math.abs(Math.round((document.body.clientHeight-50)/ 2)), 150, 83, document.body);
    });
    DWREngine.setPostHook(function() {    //这是加载完成的代码
       obj.innerHTML = "show user";
        oPopup.hide();
    });
}

    </script>
</head>
<body>
<a style="cursor:hand" id="" onclick="var showID='div_show';if ($(showID).style.display == 'none') {changeStatus(this);userAction.getUserList(showID, showUser); } else {$(showID).style.display = 'none';}">show Users</a> <br>

<div id="div_show" style="display:none"></div>

</body>
</html>